package com.ellricky.baselib.ui.clue

import android.os.Bundle
import android.view.View
import android.widget.AdapterView
import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.andr.common.widget.refresh.RvRefreshListener
import com.ellricky.baselib.adapter.clue.ClueCtAdapter
import com.ellricky.baselib.cache.LocalCacheUtil
import com.ellricky.baselib.entity.clue.ClueCtEntity
import com.ellricky.baselib.entity.new.ClueCt
import com.ellricky.baselib.http.Api.API_CT_LIST
import com.ellricky.baselib.http.callback.EListCallback
import com.ellricky.baselib.ui.base.BaseRefreshFragment
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.baselib.util.NewEBaseCallback
import com.ellricky.baselib.util.NewEListCallback

/**
 * 线索库-课程顾问
 */
class ClueCtFragment : BaseRefreshFragment<Void, BasePresenter<Void>, ClueCt>(), RvRefreshListener,
    AdapterView.OnItemClickListener {

    companion object {
        fun newInstance(): ClueCtFragment {
            val fragment = ClueCtFragment()
            val bundle = Bundle()
            fragment.arguments = bundle
            return fragment
        }
    }

    override fun initUIView(view: View?) {
        super.initUIView(view)
        hideToolBar()
    }


    override fun getResponseCallback(): BaseCallback? {
        return null
    }

    override fun getRvAdapter(): BaseRecyclerAdapter<ClueCt> {
        return ClueCtAdapter()
    }

    override fun getResponseCallback2(): NewEBaseCallback {
        return object : NewEListCallback<ClueCt>(mContext) {
            override fun onSuccess(data: MutableList<ClueCt>, msg: String) {
                dataSource = data
                rvView.onLoadFinish(data, refresh)
            }
        }
    }

    override fun getUrlPath(): String {
        return ""
    }

    override fun initParamMap() {
        paramMap.put("action", "headSaleList")
        paramMap.put("eid", LocalCacheUtil.getUid())
    }

    override fun onItemClick(adapterView: AdapterView<*>?, view: View?, i: Int, l: Long) {
        val id = adapter[i].Id.toString()
        EAppUtil.jumpPageWithId(this, MyClueActivity::class.java, id)
    }
}
